Extension::MongoDBUpdateRecord Method
Syntax
c UpdateRecord(C id, C data)
Arguments
- id
_id for an existing document.
- data
JSON, ommiting the _id field for the replacement.
Description
Updates a document db record using 'id'.
dim mongo as extension::MongoDB = extension::MongoDB::Create("mongodb://localhost:27017","TestDatabase","flowers") dim json as c = mongo.GetRecords("{ \"Id\" : \"00000062\" }") dim recs as p = json_parse(json) ? recs[1] = _id = "6065f82cdbef84456ce731dd" Id = "00000062" Imagedate = "08/12/2001" Keywords = "rudbekia daisy yellow" Picture = =filename_decode("Hires\rudbekia.jpg") dim recs[1].description as c = "Also known as Black Eyed Susans" dim id as c = recs[1]._id delete recs[1]._id mongo.UpdateRecord(id,json_generate(recs[1]))
Update allows you to modify a document with a known id field.
It is important to not include the _id field in the supplied data, which is why in this example the _id field is deleted in the xbasic.